package com.mql.ganio.ui.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.mql.ganio.R;
import com.mql.ganio.ui.base.BaseFragmentActivity;
import com.mql.ganio.ui.presenter.ViewBigImagePresenter;
import com.mql.ganio.ui.view.ViewBigImageAtView;
import com.mql.ganio.widget.HackyViewPager;

import java.util.List;

import butterknife.Bind;

public class ViewBigImageActivity extends BaseFragmentActivity <ViewBigImageAtView,ViewBigImagePresenter>implements ViewBigImageAtView,View.OnClickListener{


    @Bind(R.id.very_image_viewpager)
    HackyViewPager veryImageViewpager;
    @Bind(R.id.very_image_viewpager_text)
    TextView veryImageViewpagerText;
    @Bind(R.id.tv_save_big_image)
    TextView tvSaveBigImage;
    // 接收传过来的uri地址
    List<String> imageuri;
    // 接收穿过来当前选择的图片的数量
    int code;
    // 用于判断是头像还是文章图片 1:头像 2：文章大图
    int selet;

    /**
    /**
     * 用于判断是否是加载本地图片
     */
    private boolean isLocal;

    /**
     * 本应用图片的id
     */
    private int imageId;
    /**
     * 是否是本应用中的图片
     */
    private boolean isApp;

    @Override
    public void initData() {
        mPresenter.setAdapter();
    }

    @Override
    public void initView() {
        /************************* 接收传值 ***********************/
        Bundle bundle = getIntent().getExtras();
        code = bundle.getInt("code");
        selet = bundle.getInt("selet");
        isLocal = bundle.getBoolean("isLocal", false);
        imageuri = bundle.getStringArrayList("imageuri");
        /**是否是本应用中的图片*/
        isApp = bundle.getBoolean("isApp", false);
        /**本应用图片的id*/
        imageId = bundle.getInt("id", 0);
        Log.e("---->","code:"+code+"imageuri:"+imageuri.toString());
        if (isLocal){
            tvSaveBigImage.setVisibility(View.GONE);
        }
    }

    @Override
    public void initListener() {
        tvSaveBigImage.setOnClickListener(this);
    }

    @Override
    protected ViewBigImagePresenter createPresenter() {
        return new ViewBigImagePresenter(this,isLocal,imageId,isApp,selet,code,imageuri);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_view_big_image;
    }


    @Override
    public HackyViewPager getHackyViewPager() {
        return veryImageViewpager;
    }

    @Override
    public TextView getVeryImageViewpagerText() {
        return veryImageViewpagerText;
    }

    @Override
    public TextView getTvSaveBigImage() {
        return tvSaveBigImage;
    }

    @Override
    public void onClick(View v) {
        mPresenter.saveImg();
    }
}
